package API.DateDome.LocalDateTimeDome;

import java.time.Duration;
import java.time.LocalDateTime;

/**
 * ClassName:LocalDateTimeText007
 * Package:API.DateDome.LocalDateTimeDome
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/2/2-19:36
 * @Version:v1.0
 */
public class DurationDome {
    public static void main(String[] args) {
        LocalDateTime nowlocalDateTime = LocalDateTime.now();
        System.out.println(nowlocalDateTime);

        //出生日期的时间对象
        LocalDateTime birthDate = LocalDateTime.of(2000,4,4,
                4,4,4,5452);
        System.out.println(birthDate);

        Duration duration = Duration.between(birthDate,nowlocalDateTime);
        System.out.println("相差的时间间隔对象："+duration);

        System.out.println("========================================");
        System.out.println("两个时间相差的天数："+duration.toDays());
        System.out.println("两个时间相差的小时："+duration.toHours());
        System.out.println("两个时间相差的分钟数："+duration.toMinutes());
        System.out.println("两个时间相差的毫秒数："+duration.toMillis());
        System.out.println("两个时间相差的纳秒数："+duration.toNanos());
    }
}
